home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 8
/
Night Owl CD-ROM (NOPV8) (Night Owl Publisher) (1993).ISO
/
017a
/
asic.arj
/
ASIC.DOC
next >
Wrap
Text File
|
1990-03-04
|
108KB
|
4,152 lines
m6CB
+--------------------------------------------------------------------+
| |
| A S I C 1.0 |
| |
| "Its Almost Basic" |
| |
| |
| Copyright 1989 |
| by |
| David A. Visti |
| |
| All Rights Reserved |
+--------------------------------------------------------------------+
| ASIC may be used for personal use at no charge (of course, |
| contributions are always welcome). Commercial users are |
| asked to send in a $10 registration fee. Also, feel free to |
| distribute this software to others. However, you may not |
| charge for the distribution of this software to others nor may |
| you alter the software or this documentation. |
| |
| I'm always striving to improve the quality of my software, so |
| please pass your suggestions along to me. I hope you enjoy |
| using ASIC! |
+--------------------------------------------------------------------+
| |
| Please send registration fees and suggestions to: |
| |
| David Visti |
| P.O. Box 2952 |
| Raleigh, NC 27602-2952 |
| |
| Please mention the version of ASIC in any correspondence |
| (This is ASIC Version 1.0) |
+--------------------------------------------------------------------+
| I can also be reached for questions/comments on GEnie and |
| Compuserve via EMAIL: |
| |
| Compuserve 73065,1302 |
| GEnie D.VISTI |
| |
+--------------------------------------------------------------------+
| |
| DISCLAIMER: This software is provided "as is" without warranty |
| of any kind. In no event shall I be held liable for any |
| damages whatsoever arising from the use of or inability to use |
| this product. |
| |
+--------------------------------------------------------------------+
A S I C
Table of Contents
Chapter Title
1. Getting Started Page 3
2. Tutorial Page 5
3. Integrated Editor/Compiler Environment Page 10
4. Stand-alone Compiler Options Page 16
5. Language Elements Page 19
6. Keyword Reference Page 23
ABS Page 23
ASC Page 23
CHR$ Page 24
CLOSE Page 24
CLS Page 25
COLOR Page 25
CRSLIN Page 26
DEFSEG Page 26
DIM Page 27
END Page 27
FOR/NEXT Page 28
GOSUB Page 30
GOTO Page 30
IF/THEN/ELSE Page 31
INKEY$ Page 32
INPUT Page 33
INPUT# Page 34
LEN Page 35
LOCATE Page 35
LPRINT Page 36
MID$ Page 37
OPEN Page 37
PEEK Page 38
POINT Page 38
POKE Page 39
POS Page 39
PRESET Page 40
PRINT Page 41
PRINT# Page 42
PSET Page 43
RANDOMIZE Page 44
Page - 1
Table of Contents (Continued)
Chapter Title
5. Keyword Reference (Continued)
REM Page 44
RETURN Page 44
RND Page 45
SCREEN Page 46
SOUND Page 47
STR$ Page 47
VAL Page 48
VARPTR Page 48
WIDTH Page 49
ZMODE Page 49
7. Compatibility with BASICA/GWBASIC Page 50
8. Technical Details/Tips Page 52
9. Error Messages Page 55
Page - 2
A S I C
Chapter 1
Getting Started
INTRODUCTION
Welcome to ASIC!
ASIC is a "BASIC" programming language compiler for IBM PC's and
compatibles. It includes an integrated full screen editor, from which
you can edit, compile, and execute your programs. Or at your option,
you can use your own text editor, and compile your programs from the
MS DOS command line.
ASIC is a subset of BASICA and GWBASIC which supports over 40
BASIC statements, integer and string variables, and integer arrays.
It will compile your programs at high speed, and the code it generates
is fast and compact. The syntax of each ASIC statement is generally a
valid subset of the syntax used by BASICA and GWBASIC (exceptions are
noted in Chapter 7.)
All you need to get started is:
1) ASIC
2) IBM PC or 100% Compatible
3) 320-400k Available Memory*
4) Two floppy disk drives
<or>
One hard disk drive and one floppy disk drive
The first step is to install ASIC as described below. Then,
proceed to Chapter 2 for a brief ASIC tutorial. Following that you
can read the remainder of the documentation straight through, or refer
to it as you need it. Have Fun!
* The ASIC Compiler and Editor will each run in 320k of memory,
however, to compile from within the editor, requires 400k of
memory. If ASIC does not find sufficient memory to call the
compiler from within the editor, it will ignore the compile
request and return to the editor.
Page - 3
INSTALLATION
To install ASIC execute the following commands as appropriate for
your machine. The procedure to do so is provided below for both
floppy systems and hard disk based systems. Also refer to the README
file on your ASIC Diskette for additional information.
TWO-FLOPPY DISK SYSTEM INSTALLATION
1) Make sure that the following files are all on the same diskette
(the diskette that contains these files will be referred to in this
manual as the "Compiler" diskette):
ASIC.EXE
ASICC.EXE
2) Format one or more blank diskettes to hold your programs (these
diskettes will be referred to in this manual as your "Program"
diskettes):
Note: Whenever you see the symbol <enter> in this
document, this refers to the <enter> or <return> key
on your keyboard.
HARD DISK SYSTEM INSTALLATION
1) Type: C: <enter>
2) Type: MD C:\ASIC <enter>
3) The next step is to copy the ASIC software to the ASIC directory.
If your ASIC software is on a floppy, insert the floppy in Drive
A: then type the command:
COPY A:*.* C:\ASIC <enter>
If your ASIC software is already on a hard disk directory, copy
it to the ASIC directory with the command:
COPY C:\directoryname\*.* C:\ASIC <enter>
Note that ASIC will run from any subdirectory, however, the
tutorial assumes ASIC is under C:\ASIC
Note: Whenever you see the symbol <enter> in this
document, this refers to the <enter> or <return> key
on your keyboard.
Page - 4
A S I C
Chapter 2
Tutorial
ASIC programs look very much like regular "BASIC" programs which you
are probably already familiar with. The one very noticeable
difference is that ASIC programs have no line numbers. Let's take a
look at a very simple program written both in GWBASIC/BASICA and in
ASIC:
GWBASIC/BASICA ASIC
--------------------------+----------------------------------
|
10 I=I+1 | ADDONE: I=I+1
20 PRINT I | PRINT I
30 IF I<100 THEN 10 | IF I<100 THEN ADDONE:
--------------------------+----------------------------------
Both of these programs do the same thing. They display the
numbers from 1 to 100. However, notice that ASIC allows you to use
descriptive labels (ADDONE) instead of a line number (10). These
labels can be up to 80 characters long! Also note that the ASIC
"PRINT" and "IF" statements were indented only for increased program
readability. The ASIC program could just as well have been written
as:
ASIC
------------------------------
ADDONE:I=I+1
PRINT I
IF I<100 THEN ADDONE:
------------------------------
We could have made our variable names longer. Instead of "I" we
could have chosen "SECONDS" or "VELOCITY", or some other name up to 80
characters in total. In ASIC, variable names, labels, and string
constants can all be up to 80 characters in length.
Well, now that we've seen a basic ASIC program, let's try to
enter and run a slightly larger program. The program we will be
working with will print the message "HELLO yourname" in 256 color
combinations. If you have a monochrome display card, don't worry, the
program will work, but instead of seeing different colors you'll see
characters with different attributes, such as blinking, underlined,
etc.
Page - 5
Let's get started. If you haven't done so already, install ASIC
as described in Chapter 1. Now then, writing an ASIC program involves
these three steps.
1. Write your program.
2. Compile your program.
3. Run your Program.
These three steps can all be performed from within the ASIC
Integrated Environment. Before we proceed with our "Hello yourname"
Program, let's go over some conventions.
In the following section:
FLOPPY TYPE--> Means that only 2-floppy disk system users
should type this line.
HARD TYPE--> Means that only hard disk system users
should type this line.
TYPE--> Means that both floppy and hard disk users
should type this line.
X> This is a representation of the prompt from
PC-DOS or MS-DOS. Floppy Disk Users will
actually see "A>" for a prompt. Hard Disk
Users will see "C>" for a prompt.
<enter> Means that you should press the <enter>
or <return> key on your keyboard.
<?> Text enclosed between the "<" and the ">"
symbols indicate a key to type. Don't type
the "<" or ">" symbols. For example, if the
tutorial lists "<F1>", your should press the
"F1" key on your keyboard.
NOTE: Floppy Disk users need to insert their ASIC Compiler diskette
in Drive A: at this point, and a Program diskette in Drive B: (See
the Installation section for more information)
Let's begin:
FLOPPY TYPE--> A: <enter>
HARD TYPE--> CD C:\ASIC <enter>
The computer should respond:
X>
Now enter the command to invoke ASIC
Page - 6
TYPE--> ASIC <enter>
You are now in ASIC. The top line is the Menu Bar. The bottom line
is the Status Line. Chapter 3 describes these features in more
detail. For now, we'll just describe a couple of features on these
lines.
The status line indicates that the current mode is "INSERT". This
means that any characters you type on a line will be inserted between
the existing characters. If you press the <INS> key on the keypad,
ASIC will toggle to it's other mode, OVERSTRIKE. In this mode, when
you type a character, it overlays the character that was there before.
Each time you press the <INS> key, ASIC will toggle between the INSERT
and OVERSTRIKE modes.
You can open the menus listed on the "Menu Bar" by holding down the
ALT key while typing the Capitalized letter of the menu you wish to
open. For example, to open the File menu, press <ALT><F>. The "File"
menu will pop open. You can select a menu option from that menu by
typing the capitalized letter of the option, or by using the arrow
keys on your keypad to highlight the option you want and then pressing
<enter>. Let's leave this menu for now. To do so, press the <ESC>
key. The <ESC> key will always let you escape from any menu in ASIC,
without taking any action.
If you need help, press the <F1> key for a quick summary of some of
ASIC's features. Chapter 3 gives a full description of the ASIC
Editor Commands which are available.
Entering a program in ASIC is simplicity itself. We'll simply type in
each line, pressing <enter> at the end of each line. If you make a
typing mistake, just use the arrow keys to move to the error, and type
in the correction. Use the <DEL> or <Backspace> keys to delete any
unwanted characters from the screen.
Make sure the status line says "Mode: Insert". This is the default
mode in ASIC. If it doesn't, press the <INS> key until it does. Now
let's enter our program (the program below intentionally contains an
invalid ASIC statement. We'll correct the line later in the tutorial,
for now, type in the program exactly as it's listed below):
TYPE--> CLS <enter>
TYPE--> PRINT "Please enter your name"; <enter>
TYPE--> INPUT YOURNAME$ <enter>
TYPE--> FOR I=1 TO 16 <enter>
TYPE--> FOR J=1 TO 16 <enter>
TYPE--> COLOR I,J <enter>
TYPE--> PRINT "HELLO "; <enter>
TYPE--> PRINT YOURNAME$; <enter>
TYPE--> NEXT J <enter>
TYPE--> NEXT I <enter>
TYPE--> CLS <enter>
TYPE--> THE END <enter>
Page - 7
There, that was easy. Now, let's compile our program. To do it,
we'll open the "Compile" menu, and select the "Compile program"
option:
TYPE--> <ALT><C>
The "Compile" menu will pop open. The first option, "Compile program"
can be selected by typing the option letter which is capitalized "C",
or by moving the highlight bar to this option and pressing the <enter>
key. Since the highlight bar is already on this option, let's just
press <enter>:
TYPE--> <enter>
Since we didn't specify a file name when we invoked ASIC, ASIC will
now ask for a file name (so it can save your program before calling
the compiler):
FLOPPY TYPE--> B:TUTOR.ASI <enter>
HARD TYPE--> TUTOR.ASI <enter>
Note that ASIC requires that your programs be stored in files ending
with the extension ".ASI". Had we entered "TUTOR" for our program
name, ASIC would have appended the letters ".ASI" for us. If we tried
to provide a different extension, such as "TUTOR.SRC", ASIC would
display an error message. Also, whenever you are presented a dialog
box where you are asked to enter text (such as file name, or Y/N
responses to questions), you must press the <enter> key before ASIC
will accept the input.
Once you select the "Compile program" option, you'll see the ASIC
compiler screen appear. It will display a count of the lines
compiled, and when it is done, it will return to the ASIC editor.
If it detected any errors, it will display the first error message at
the bottom of the editor screen. It will also highlight the line in
your program which is in error. In this case the line "THE END" was
flagged with the error message "Syntax Error". Of course, that line
should have been entered simply as "END".
That should be easy enough to fix. Let's exit the error menu by
pressing the <ESC> key:
TYPE--> <ESC>
The error menu has disappeared, and our cursor is now on the erroneous
line. To fix the line:
TYPE--> <DEL><DEL><DEL><DEL>
Page - 8
That should do it. The last line of our program should now read
"END". Let's recompile the program:
TYPE--> <ALT><C>
TYPE--> <enter>
This time you should see the message "No Compiler Errors". If you
didn't, check your spelling and recompile the program until you
receive this message. Press <ESC> to remove the "No Compiler Errors"
Window.
Now let's run the program. To do so, we'll open the "Compile" menu,
and select the "Run your program" option.
TYPE--> <ALT><C>
TYPE--> <r>
This time, we just entered the capitalized letter from the menu option
"Run your program". Your computer screen should now prompt you to
"Please enter your name?". Go ahead and enter your name now:
TYPE--> yourname <enter>
You should see "HELLO yourname" printed in various color combinations,
and then the ASIC editor screen will reappear. Well, that's all there
is to writing, compiling, and running an ASIC program. Now, to exit
ASIC, open the "File" menu and select the "eXit" option.
TYPE--> <ALT><F>
TYPE--> <X>
You should see your MS DOS prompt once again. By the way, now that
you've successfully compiled the program, you can execute it directly
from MS DOS. Let's try it:
HARD TYPE--> TUTOR <enter>
FLOPPY TYPE--> B:TUTOR <enter>
Well, that's a brief introduction to ASIC! Next, you might want to
read Chapter 3, "Integrated Editor/Compiler Environment" to learn
about the many other features available in the ASIC editor. Chapters
5-7 describe the BASIC statements which are supported by ASIC.
Chapter 9 provides more descriptive information for ASIC error
messages.
Hope you enjoy programming in ASIC!
Page - 9
A S I C
Chapter 3
Integrated Editor/Compiler
Environment
INTRODUCTION
The ASIC integrated environment lets you edit, save, compile, and
run your ASIC programs without ever leaving ASIC! This chapter will
explain the usage of the integrated environment.
ASIC SCREEN CONTENTS
ASIC divides the screen into three parts. The top line is called
the "Menu Bar". All of the menu's available to you are listed on this
line. The bottom Line is called the "Status Line". It continuously
displays some important program information. The middle 23 lines are
the "Edit Window". This is the section of the screen where you can
make changes or additions to your program.
MENU BAR PROCESSING
Currently, there are three menu's available. The "File" menu allows
you to load/save your existing program files to/from disk. It is also
used to exit ASIC. The "Edit" menu contains various editing commands
which are available. The "Compile" menu is used to compile your
program, run your program, set compiler options, and to view compiler
errors.
To open a menu, hold down the <ALT> key and type the first letter
of the menu. The menu will pop down and display the options available
on that menu. If you want to close the menu without taking any
action, press the <ESC> key. Otherwise, to select an option, either
type the capitalized letter of the menu option. For example, on the
"File" menu, to select the "eXit" option, type an "X" or an "x".
Another way to select an option is to move the "Highlighted Bar" down
to the option you wish to select, and press the <enter> key.
Now let's describe the options available on each menu.
Page - 10
FILE MENU
"Open" Option
This option allows you to open an existing ASIC file and load it
into the ASIC edit buffer where you can modify it. If you select this
option another window will open to ask you the file name. If you
don't wish to open a file, you can press <ESC> to close the menu
without taking any action. Otherwise, enter an ASIC file name, and
press the <enter> key.
"Save" Option
This option allows you to write the changes you've made to your
program back to the file. Changes you enter in the ASIC editor are
made to memory only. You must select this option before your changes
will become permanent. Note: Your file is saved to disk
automatically whenever you compile it, or run it, if the file modified
indicator is set.
"save As" Option
This option will allow you to write the changes you've made to
the program in the edit buffer to a new file. You will be prompted to
provide ASIC with a new file name.
"eXit" Option
This option will allow you to exit from ASIC back to MS DOS.
ASIC will ask you if you wish to save your file before you exit.
EDIT MENU
"Begin block" Option
This option will allow you to mark the beginning of a block of
text for use with the block delete, copy, and move commands described
below. To mark a block of text, move the cursor to the first line of
the block, and then select this option. The beginning line of the
block will be highlighted on the screen. Next, move the cursor to the
ending line of the block, and select the "End block" option from this
menu. All of the lines in the block will be highlighted. This block
of lines can now be "moved", "copied", or "deleted" using the block
commands described below.
"End block" Option
This option will allow you to mark the end of a block of text.
Refer to the "Begin block" Option above for more information.
Page - 11
"Delete block" Option
This option will delete a block of lines. Refer to the "Begin
block" option above for information on marking a block of lines. If
you haven't marked a block of lines, selecting this option will have
no effect.
"Move block" Option
This option will move a block of lines to a new location in the
edit buffer. Refer to the "Begin block" option above for information
on marking a block of lines. If you don't mark a block of lines,
selecting this option will have no effect. Once you have marked a
block of lines, move the cursor to the location in the edit buffer
where you want the lines moved. Selecting the "Move block" option will
result in the block of lines being deleted from their current
location, and moved to the buffer at the line following the cursor.
ASIC will not overlay lines, it will insert enough blank space to hold
the relocated text.
"Copy block" Option
This option is the same as the "Move block" option, with one
exception. After moving the block, ASIC does NOT delete the original
block of lines. Use this option to clone a block of text.
"Search" Option
This option allows you to locate a string of characters in the
edit buffer. When you select this option, ASIC will ask you for a
search string which can be up to 30 characters in length. ASIC will
then search forward from the current line until it finds the string or
reaches the end of the edit buffer. If it finds the string, the
cursor will be placed on the line containing the string.
"Replace" Option
This option will allow you to replace one or more occurrences of
a string of characters with another set of characters. When you
select this option, ASIC will ask you for a search string which can be
up to 30 characters in length. ASIC will then ask you for the string
of characters which is to replace the search string. Finally, ASIC
will ask you to specify how many occurrences of this search string are
to be replaced (from 1-9999). ASIC will search forward from the
current line, and briefly display each line as it modifies it. If it
reaches the end of the edit buffer before it has replaced the number
of occurrences you've specified, ASIC will display and "End of Buffer"
message, and stop.
Page - 12
COMPILE MENU
"Compile program" Option
Use this option to have ASIC compile the program which is
currently loaded in the edit buffer. If the compile is successful,
ASIC will display the message "No Compiler Errors". Otherwise, it
will display the first error message (see "View compile errors" option
below). ASIC will automatically save your program before calling the
compiler.
"Full program listing" Option
This menu option, and the next two options are used to toggle
various compiler options on or off. When the option is on, you will
see a "{" symbol next to the option. This compiler option will cause
ASIC to display each source line as it compiles it. This option will
slow down the compile, but since ASIC also writes these lines to a
listing file, this option can be used to create a compile listing.
The compile listing will be contained in a file called "progname.LST",
where "progname" is the name of your program.
"Printer output" Option
This menu option, will toggle the "Printer output" option on or
off. When the option is on, you will see a "{" symbol next to the
option name. This compiler option will cause compiler messages to be
printed on your printer.
"Symbol table" Option
This menu option, will toggle the "Symbol table" option on or
off. When the option is on, you will see a "{" symbol next to the
option name. This compiler option will cause ASIC to create a symbol
table file called "progname.SYM", where "progname" is the name of your
program. The symbol table is a list of all variables, labels, and
internally created compiler addresses.
"Run your program" Option
After you have successfully compiled your program, you can select
this option to cause ASIC to load and execute your program. After
your program ENDs, ASIC will return you to the editor. ASIC will save
the edit buffer before loading and executing your program.
Page - 13
"View compile errors" Option
When you wish to examine the errors from a previous compile of
your program, select this option. If no errors exist, ASIC will so
inform you. Otherwise, ASIC will display the first error message at
the bottom of the screen, and it will highlight the line of your
program which corresponds to that error. If you wish to correct the
program line, press the <ESC> key. The cursor will be positioned at
the beginning of that program line. You may also view subsequent
compiler errors by pressing the <F10> key instead of the <ESC> key.
STATUS LINE
The bottom line of the ASIC screen is called the "Status Line".
As it's name implies, it is used to display various types of status
information. At the left of the status line "FILE: xxxxxxxx.xxx" will
display the name of the file which is currently loaded in the edit
buffer. If you haven't opened a file yet, the file name will be
blank.
After the file name is the "File Modified Indicator". If you
have entered any changes in the edit buffer, and have not saved them
to disk, an "*" will appear to indicate this. If the edit buffer has
not been modified since the last save to disk, no "*" will be present.
The next piece of information is "Mode:". Mode will always
display one of two values: "Insert" or "Ovrstr". In "Insert" mode,
any characters you type in the edit buffer will be inserted at the
cursor position, and the characters to the right of the cursor will be
shifted to the right by one. In "Ovrstr" mode, any characters you
type in the edit buffer will overlay (and thus destroy) the character
at the cursor position. You can change back and forth between these
two modes by pressing the <INS> key on your keypad.
To the right of "Mode:" ASIC displays the number of bytes which
it allocated to the edit buffer. Divide this number by 81 to get a
rough idea of how many lines will fit in the edit buffer.
The "Line: nnnn" status indicator, will identify which line of
the file is being displayed. For example, if the display reads "Line:
100", the line containing the cursor is the 100th line in the file.
The "Row:" and "Col:" numbers identify the relative position of
the cursor within the "Edit Window".
Page - 14
EDIT WINDOW
The edit window is the area of the screen where your program is
displayed. It displays 23 lines of your program at a time. You can
use the keys described below to manipulate the text in this window.
KEYBOARD USAGE
Most keys on the keyboard behave in ASIC just as you'd expect.
The key usages which might not be obvious are described here.
<ESC> Exit from any menu without taking any action.
<TAB> Move the cursor to the next "tab stop". Tab stops in
ASIC are fixed at every fourth column (4,8,12,etc).
<HOME> Move the cursor to the beginning of the current line.
<END> Move the cursor to the last non-blank character on the
current line.
<DEL> Delete the character at the cursor position.
<INS> Toggle between Insert and Overstrike Modes.
<PGUP> Display the previous 23 lines in the edit buffer.
<PGDN> Display the next 23 lines in the edit buffer.
<Ctl-PGUP> Display the first 23 lines in the edit buffer.
<Ctl-PGDN> Display the last 23 lines in the edit buffer.
<Backspace> Delete the character at the cursor position, and
move the cursor one column to the left.
<Up Arrow> Moves cursor up one line.
<Down Arrow> Moves cursor down one line.
<Left Arrow> Moves cursor left one column.
<Right Arrow> Moves cursor right one column.
<Alt-D> Delete the line containing the cursor.
<Alt-A> Add a line following the line containing the cursor.
<enter> In Insert mode, pressing <enter> is identical to
pressing <Alt-A>. In OvrStr mode, pressing <enter>
is identical to pressing the <Down Arrow> key.
Page - 15
A S I C
Chapter 4
Compiler Options
COMMAND LINE SYNTAX
Invoke the command line version of the compiler as follows:
ASICC filename option1 option2 option3 option4 option5 option6
Where: filename is the name of the source program to be
compiled. This file must have the file
extension ".ASI", although the extension
may be omitted from the command line.
optionN specifies any options desired. No
options are required, but as many as
six may be specified.
COMPILER OPTIONS
A total of five compiler switches are currently available for ASIC.
Each is described in detail below:
Switch Description
C CONTINUE--ASIC will not pause after messages are
issued, but will continue compiling.
Default: ASIC will pause after each error message.
Compilation will resume after you press
a key.
Page - 16
Switch Description
L LIST ALL--ASIC will list each source line as it
compiles it.
Default: ASIC will list only source lines with
compile errors.
Comment: Use of this switch will slow compile
speeds slightly due to the additional
screen I/O.
P PRINTLIST--ASIC will echo all messages which
appear on the screen to the printer.
Output to the printer will be paged
with header lines identifying the
program name, and the date/time
compiled.
Default: ASIC will not send any messages to
the printer.
Comments: Even though output to the printer is
buffered, this option will slow compile
speeds considerably. The compiler typically
compiles only as fast as your printer
can print the messages. An alternative
to this switch is the DISKLIST option
described below.
D DISKLIST--ASIC will echo all screen messages to a disk
file named "progname.LST". The format is
the same produced by PRINTLIST. This allows
you to compile at higher speed, and print
the source listing later from the disk file
via the DOS print spooler.
Default: ASIC does not produce a ".LST" file.
S SYMTAB----ASIC will produce a formatted Symbol Table
in a file named "progname.SYM". The symbol
table contains a list of all variables,
labels, and internally created compiler
addresses.
Default: ASIC does not produce a ".SYM" file.
Page - 17
COMPILE EXAMPLES
Example 1: Compile "MYFILE.ASI" with default compiler options:
ASICC MYFILE
Example 2: Compile "MYPROG.ASI", Listing all source lines, writing
a compile listing to a disk file for printing later. The
listing file will be called "MYPROG.LST":
ASICC MYPROG L D
Example 3: Compile "FILEX.ASI", don't pause for any errors, and
print the errors on the printer:
ASICC FILEX C P
Page - 18
A S I C
Chapter 5
Language Elements
CHARACTER SET
Symbol Description
* Multiplication
Example: A=B*C (multiply B by C, store result in A)
/ Division
Example: A=B/C (divide B by C, store result in A)
+ Addition
Example: A=B+C (add C to B, store result in A)
+ String Concatenation
Example: A$="AB"+"C" (A$ will contain "ABC")
= Assignment
Example: A=1 (A will be assigned the value 1)
= Equality testing
Example: IF A=1 THEN QUIT: (If the value stored in
(A equals 1 goto label QUIT)
- Subtraction
Example: A=B-C (Subtract C from B, store result in A)
" String Delimiter
Example: A$="the string is inside quote marks"
() Parenthesis -- Ignored by ASIC
Page - 19
Symbol Description
; Suppress Carriage Return/Line Feed with PRINT/LPRINT
# Used to identify file usage with PRINT#/INPUT#
, Comma, Ignored by ASIC
$ Distinguishes a String Variable from an Integer.
Example: ABC$ <---- string variable
Example: ABC <---- integer variable
: Distinguishes a Label from a variable name.
Example: START: <---Label name
Page - 20
CONSTANTS, VARIABLES, AND LABELS
ASIC supports the following data types: Integer Constants, Integer
Variables, single dimension Integer Arrays, String Constants, and
String Variables. The following describes the restrictions for each
data type.
INTEGER CONSTANTS Range +32767 to -32767
Example: -26
INTEGER VARIABLE Described by a variable name beginning with a
letter, followed by up to 79 additional letters
or numbers. It may contain a number in the range
+32767 to -32767.
Example: VELOCITY1
INTEGER ARRAY Described by a variable name beginning with a
letter, followed by up to 79 additional letters
or numbers. This name is followed by an
integer variable or constant for the dimension
of the array. Arrays must be dimensioned at the
beginning of the program. See the DIM statement.
Example: GROWTH (YEAR)
STRING CONSTANT A group of 0-80 characters enclosed by quotation
marks.
Example: "This is a String Constant"
STRING VARIABLE Described by a variable name which begins with a
letter, followed by up to 78 additional
letters or numbers, terminated with a "$".
Can contain 0-80 characters.
Example: ADDRESS$
LABEL A Label is a location in your program you wish
to transfer to. It must begin with a letter,
and it may contain up to 78 additional letters
or numbers. It must be terminated with a ":".
Example: START:
Page - 21
VARIABLES VS. CONSTANTS
In general, ASIC will allow the use of either variables, arrays, or
constants as operands to any program statement. For example:
PRINT CASH
PRINT 20
PRINT A(10)
All three of the above examples are valid. The only case where a
constant cannot be used, is where the value is being modified. For
example:
A = A + B <----VALID
17 = A + C <----INVALID
Of course you must specify the correct data type for the ASIC keyword.
For example:
A = ABS("HELLO") <----INVALID
This statement is invalid because you cannot take the absolute value
of a string!
There are a few ASIC statements which will accept only integer
constants for some operands (DIM, OPEN, PRINT#, INPUT#). Refer to the
individual statement for more information.
Finally, there is a restriction on the use of subscripts for Arrays.
A subscript for an array cannot be another array. For example:
A(I(1)) <----INVALID
A(I) <----VALID
Page - 22
A S I C
Chapter 6
Keyword Reference
ABS
Format: integer1 = ABS (integer2)
Description:
This function returns the absolute value of integer2 which is
then stored in integer1.
Example:
A = ABS (-7)
After execution of this statement, "A" will contain 7.
ASC
Format: integer1 = ASC (string1)
Description:
This function returns the ASCII value of the first character of
string1, storing the result in integer1.
Example:
A = ASC("123")
After execution of this statement "A" would contain 49, which the is
ASCII value of "1".
Page - 23
CHR$
Format: string1 = CHR$(integer1)
Description:
This function converts an integer in the range of 0-255 to an
ASCII character, and stores in string1.
Example:
A$ = CHR$(49)
After execution of this statement, "A$" will contain "1", since "1" is
represented by ASCII 49.
Comments:
If integer1 is outside the range 0-255, then the least
significant byte of integer 1 is converted to string1.
CLOSE
Format: CLOSE integer1
Description:
This function closes the file number identified by integer1. If
an error is returned by DOS, the system variable "ERROR" will be > 0.
Example:
CLOSE 1
IF ERROR > 0 THEN CHECKERROR:
After successful execution of the CLOSE statement, the file previously
opened as file 1 will be closed. If an error is returned by DOS, the
ERROR variable will be set by ASIC to a non-zero value.
Comments:
IF YOU FAIL TO CLOSE AN OPEN FILE (WHICH WAS OPENED FOR WRITING),
YOU MAY LOSE DATA, SINCE FILE I/O IS BUFFERED, AND THE LAST BUFFER MAY
NOT HAVE BEEN FLUSHED.
Also, integer1 may only be a constant with the value of 1-3.
See Also:
OPEN,PRINT#,INPUT#
Page - 24
CLS
Format: CLS
Description:
This function clears the screen.
COLOR
Format: COLOR integer1,integer2
Description:
This function is used to set the foreground and background screen
colors. The foreground color is specified in integer1, the background
color in integer2.
Valid Colors: Foreground Background
---------- ----------
Black 0 0
Blue 1 1
Green 2 2
Cyan 3 3
Red 4 4
Magenta 5 5
Brown 6 6
White 7 7
Dark Gray 8
Light Blue 9
Light Green 10
Light Cyan 11
Light Red 12
Light Magenta 13
Yellow 14
Bright White 15
Note: Colors 8-15 when specified for background color
result in blinking text.
Example:
COLOR 4,8
After execution of this statement, future characters written to the
screen will be Blinking Red on a Black Background.
Page - 25
CRSLIN
Format: integer1 = CRSLIN
Description:
This function returns row of the cursor.
Example:
LOCATE 10,20
A = CRSLIN
The locate command will have positioned the cursor in row 10, column
20. After execution of the CRSLIN statement, "A" will contain the
value of 10.
See also:
POS
DEFSEG
Format: DEFSEG integer1
This function is used the alter the default data segment used
when peeking and poking data with PEEK and POKE statements. DEFSEG,
PEEK, and especially POKE are not recommended for beginners. If
integer1 =-1, then the data segment address is set back to the ASIC
default data segment address.
See also:
PEEK, POKE
Page - 26
DIM
Format: DIM variable(integer1)
Description:
This statement will create one dimensional arrays. An integer
variable name must be specified in variable. Integer 1 contains the
number of elements in the array.
Example:
DIM A(10)
In this example an array of 10 integer variables is defined.
Comments:
On the DIM statement, integer1 may only be a constant. Also, DIM
statements must appear before all other statement types in the
program.
END
Format: END
Description:
This statement causes your program to terminate and return to
DOS.
Example:
IF PLAYAGAIN$ = "YES" THEN PLAYAGAIN:
END
In this example, if the variable PLAYAGAIN$ contains a value other
than "YES", then the program will terminate and return to DOS.
Page - 27
FOR/NEXT
Format: FOR integer1 = integer2 to integer3
NEXT integer1
Description:
These two statements are used to create a loop, so that you can
execute a portion of your program a certain number of times. All of
the code between the FOR and the NEXT statement will be executed a
certain number of times, but at least once. The actual number of
times the loop executes is dependent on integer1/integer2/integer3.
When the FOR statement is encountered in your program, integer1 is
assigned the value of integer2. Then the statements up to the
matching NEXT statement is executed one time. Then, 1 is added to
integer1, and integer1 is compared to integer3. If integer1 is
greater than integer3 then the control passes to the statement
following NEXT. Otherwise, the program loops back up to the statement
following the FOR statement.
Example:
FOR I = 1 TO 2
FOR J = 3 TO 5
PRINT I;
PRINT J
NEXT J
NEXT I
PRINT "AFTER THE LOOP";
PRINT I;
PRINT J;
Execution of this section of code would result in the following
printout:
1 3
1 4
1 5
2 3
2 4
2 5
AFTER THE LOOP 3 6
Comments:
Unlike BASICA/GWBASIC, ASIC FOR/NEXT loops execute at least 1
time. For example, the value "HELLO" will be printed in the following
example. It wouldn't have been in BASICA/GWBASIC.
FOR I = 1 TO 0
PRINT "HELLO"
NEXT I
Page - 28
FOR/NEXT (Continued)
Unlike GWBASIC/BASICA, arrays may be used for integer1 and
integer2. However, if integer3 is an array, element zero will be
used, regardless of the subscript you specify.
ASIC will allow you to modify the value of integer3, while
GWBASIC/BASICA ignores changes.
J=1
FOR I=1 TO J
J=2
NEXT I
The above loop will execute one time in GWBASIC/BASICA, but it
will execute two times in ASIC.
Page - 29
GOSUB
Format: GOSUB label1
Description:
This statement "calls" a subroutine called "label1". This
subroutine must contain a "RETURN". After the subroutine is executed,
control is returned to the next statement following the GOSUB.
Example:
GOSUB PRINTIT:
PRINT "All Done!"
END
PRINTIT: PRINT "It"
RETURN
After execution of this code the screen would contain:
It
All Done!
GOTO
Format: GOTO label1
Description:
This statement transfer program execution to the statement
identified by label1.
Example:
GOTO SKIPIT:
PRINT "YOU'LL NEVER GET HERE"
SKIPIT: PRINT "ALL DONE!"
After execution of this code, the screen will appear as follows:
ALL DONE!
Note that the first print statement never executes because of the
GOTO.
Page - 30
IF/THEN/ELSE
Format: IF condition THEN label1 <--Format 1
IF condition THEN label1 ELSE label2 <--Format 2
Description:
This statement is used to conditionally transfer to a different
location in the program. If "condition" is true, control is
transferred to label1. If "condition" is false, if label2 is
specified, control transfers to label2, otherwise a false condition
will cause the program to continue executing the statement following
the IF statement. The operand "condition" is one of the following:
integer1 > integer2
string1 > string2
integer1 = integer2
string1 = string2
integer1 < integer2
string1 < string2
Example:
IF A > 0 THEN APLUS:
In this example, if A is greater than zero, the program jumps to the
label called "APLUS:".
Example:
IF A$="YES" THEN TRUE: ELSE FALSE:
In this example, if A$ contains the string "YES", the program jumps to
the label called "TRUE:", otherwise the program transfers to label
"FALSE:"
Page - 31
INKEY$
Format: string1 = INKEY$
Description:
Used to retrieve keystrokes from the keyboard buffer. If a
character is waiting in the buffer, string1 will be set to the value
of that character, and that character will be removed from the
keyboard buffer. If the buffer is empty, string1 will be set to a
value of "" (that is, a null string with a length of 0). If an
extended key is pressed (for example the function keys F1 through
F10), the system variable EXTENDED will be set to 1 otherwise it will
contain 0.
Example:
LOOP: X$=INKEY$
IF X$="" THEN LOOP:
The above code will cause the program to loop until a key is pressed.
Comment:
ASIC provides an extension here over BASICA/GWBASIC. the
EXTENDED system variable will allow you to detect special keys as
mentioned above. To do so requires an understanding of keyboard scan
codes, which is beyond the scope of this manual. For more information
I would suggest Peter Norton's Programmer's Guide to the IBM PC
(Microsoft Press).
Page - 32
INPUT
Format: INPUT variable1
Description:
This statement will retrieve a line of text terminated from the
input buffer and stores it in variable1. ASIC will first issue the
prompt "?". It will then wait until the user enters a string or
integer and presses the <return> or <enter> key. The type of data
ASIC will expect is dependent on the type of variable1 (integer or
string). If an integer is being entered, ASIC will edit the input for
validity as an integer, and if the edit fails will issue another "?"
to the user, and will wait for the number to be retyped. Only when a
valid integer has been entered will variable1 be updated, and only
then will control return to your ASIC program.
Example:
PRINT "Enter a String";
INPUT A$
ASIC will issue the prompt:
Enter a String?
It will then wait until you enter a string or press enter. If you
pressed enter with no characters A$ would contain "" (ie its length
would equal 0), otherwise A$ would contain the string entered.
Example:
INPUT I
In this example ASIC will issue the prompt:
?
ASIC will then wait for you to enter a valid number. If you enter an
invalid number, say "x", ASIC will reissue the "?" prompt and wait for
you to retype your input. Once the input has been edited by ASIC, "I"
would contain the number entered.
See Also:
INKEY$
Page - 33
INPUT#
Format: INPUT# integer1, variable1
Description:
This statement will read a variable file a file identified by
file number integer1. It will be stored in variable1. If an error
occurs during the read, the system variable ERROR will be set to a
non-zero value. The possible errors are listed in the error messages
section of this manual. If you read a file past it's end, the
contents of variable1 are undefined.
Example:
INPUT#1, A$
IF ERROR=99 THEN ENDOFFILE:
In this example, a string will be read from file #1, and it will be
stored in A$. The system ERROR variable is then checked to see if End
of file was reached. Note, other ERRORS could also be returned by
INPUT#, besides error code 99. Refer to the error messages section
for more information.
Comments:
Note that integer1 must be a constant in the range of 1-3. It
identifies a file by file number which must have previously been
opened by an OPEN command.
Note that ASIC assumes that integers will be stored in files in 2-
byte binary format, which is the format ASIC writes integers.
Consequently, If a file contained a string "123", but you told ASIC to
read integer "X", then ASIC would read two bytes from the file and
interpret "12" as two binary bytes that it would then combine and
store as "X". "X" would contain the integer value 12849. Thus to
read an integer correctly, you will have had to previously written it
with an ASIC program.
See Also:
OPEN, CLOSE, PRINT#
Page - 34
LEN
Format: integer1 = LEN (string1)
Description:
This statement returns the length (number of characters) of a
string, and stores the length in integer1.
Example:
A$="abc"
LENGTH1 = LEN(A$)
After execution of these statements, LENGTH1 would contain 3.
LOCATE
Format: LOCATE row,column
Description:
This statement is used to position the cursor to a row and
column. Row and Column should be integers. Row has the range 1-25,
Column has the range 1-80. This function does not perform edits on
the ranges of row and column. Consequently using this function with
values outside these ranges will have unpredictable results.
Example:
LOCATE 10,20
PRINT "HELLO"
After execution of these statements, the message "HELLO" will appear
beginning at row 10, column 20.
Page - 35
LPRINT
Format: LPRINT printobject [;]
Description:
This statement is used to send the contents of printobject to an
attached printer. "printobject" can be any valid ASIC datatype:
integer constant, integer number, string constant, string variable,
and also array elements. Optionally, a ";" can be included with this
statement to suppress a carriage return/line feed which ASIC normally
also sends to the printer following each LPRINT. This can be used to
string several printobjects together on a single print line.
Example:
A=12345
LPRINT "The value of A is: ";
LPRINT A
After execution of these statements the printer would print:
The value of A is: 12345
Comments:
Note that if the printer is not "online" that DOS will issue
a message to "Abort, Retry, or Ignore". This could overwrite a
portion of the program display, unless not planned for.
Note also, that some printers do not begin printing until
they receive a carriage return/line feed sequence.
Page - 36
MID$
Format: string1 = MID$(string2,integer1,integer2)
Description:
This statement is used to extract a substring from string2
beginning at position integer1 within string2 and continuing for
integer2 bytes. This value is then stored in string1.
Example:
A$="THE QUICK BROWN FOX"
B$=MID$(A$,1,4)
C$=MID$(A$,11,9)
D$=B$ + C$
After execution of these statements, the contents of A$ will be
unchanged. The contents of B$ will be "THE ". The contents of C$
will be "BROWN FOX", and the contents of D$ will be "THE BROWN FOX".
OPEN
Format: OPEN string1, integer1, string2
Description:
This statement is used to open a file for input or output. Up to
three files may be open concurrently, these are known as file 1, 2, or
3. You must specify with integer1 which file number you wish to open
this file as. Integer1 may only be a constant. The file mode is
specified in string1. The valid values are "I" for INPUT and "O" for
OUTPUT. The file name is specified with string2. Any errors returned
from DOS on the OPEN call will be returned in the system variable
"ERROR".
Example:
A$="INFILE"
OPEN "I",3,A$
IF ERROR > 0 THEN PROCESSERROR:
OPEN "O",1,"A:\NEWFILE.DAT"
IF ERROR > 0 THEN PROCESSERROR:
In this example, two files are opened. File "INFILE" from the current
disk drive and directory will be opened as file number 3 for input.
The file "A:\NEWFILE.DAT" will be opened for output as file number 1.
Note that if "A:\NEWFILE.DAT" previously existed, it contents will be
destroyed in preparation for writing.
Page - 37
PEEK
Format: integer1 = PEEK (integer2)
Description:
This statement is used to examine actual memory location values
directly. By default, the ASIC DS address is assumed. However, this
may be overridden with the use of the DEFSEG command. The value of
the byte at address integer2 is stored in integer1.
See also:
DEFSEG, POKE
POINT
Format: integer1 = POINT (integer2,integer3)
Description:
This statement is used to determine the color of a given pixel in
medium and high resolution graphics modes. The row to test is
specified with integer2, the column with integer3. The color of the
pixel is stored in integer1.
Example:
PCOLOR = POINT (10,20)
After execution of this statement, PCOLOR will contain the color of
the pixel in row 10 column 20.
Comments:
No range checking is performed on row and column. If the
specified row or column is outside the valid range for the given
graphics mode, the results are unpredictable.
See also:
PSET, PRESET, SCREEN
Page - 38
POKE
Format: POKE integer1, integer2
Description:
This instruction is used store the byte value integer2 at the
memory address specified by integer1. By default, ASIC uses it's
default data segment address, however, this may be overridden with the
DEFSEG statement.
Comments:
This statement is NOT RECOMMENDED FOR BEGINNERS. Directly
overwriting memory locations can be disastrous, unless you know what
is stored at that address. This can cause program "hangs", system
crashes, etc.
See also:
DEFSEG, PEEK
POS
Format: integer1 = POS (integer2)
Description:
This statement finds the column number of the cursor and stores
it in integer1. integer2 is a dummy argument included only because a
dummy argument is required in BASICA/GWBASIC.
Example:
A = POS(0)
After this statement executes, A will contain the column number of the
cursor.
See also:
CRSLIN
Page - 39
PRESET
Format: PRESET (integer1,integer2)
Description:
This statement is used to set the color of a pixel to the
background color. The row of the pixel is specified in integer1, and
the column is specified in integer2. This statement only works in
medium and high resolution graphics modes.
Example:
PRESET (10,20)
The pixel at row 10 column 20 would be set to the background color.
See also:
PSET, SCREEN, POINT
Page - 40
PRINT
Format: PRINT printobject1 [;]
Description:
This statement is used to print to the screen. Printing begins
at the current cursor location. Printobject1 is defined as any valid
ASIC data type: integer constant, integer variable, string constant,
string variable, and arrays. The semicolon is optional and is used to
tell ASIC if you want a carriage return/line feed issued. A semicolon
at the end of a PRINT statement will suppress the carriage return/line
feed ASIC normally issues.
Example:
A=1000
PRINT "A=";
PRINT A
PRINT "DONE!"
After execution of these statements your screen would display:
A= 1000
DONE!
See also:
COLOR, SCREEN, LOCATE
Page - 41
PRINT#
Format: PRINT# integer1, printobject1
Description:
This statement is used to write integers and strings to disk.
integer1 identifies the file number that the file was opened as. The
file number, and thus integer1 must be 1, 2 or 3. integer1 must be
an integer constant. The file must have been previously opened with
the OPEN command. DOS errors are returned in the system variable
"ERROR". A list of these error codes may be found in the error
messages section of this manual. Also, refer to the technical details
section of this manual for more information on the format in which
ASIC writes the data to disk.
Example:
PRINT# 1, "HELLO"
IF ERROR = 255 THEN DISKFULL:
PRINT# 2, "WORLD"
IF ERROR = 255 THEN DISKFULL:
After successful execution of the print statement the file identified
by file number 1 would contain "HELLO0WORLD0" . Note that the "0"
following HELLO and WORLD in our example represents the ASCII null
character. Strings in ASIC are always internally terminated with
ASCII null characters.
Comments:
Note that while ASIC doesn't generate carriage returns and line
feeds for you as it does with the PRINT command, you can write these
characters to disk as follows:
A$="HELLO"
B$=CHR$(13)
A$ = A$ + B$
B$=CHR$(11)
A$ = A$ + b$
See also:
OPEN, CLOSE, INPUT#
Page - 42
PSET
Format: PSET (integer1,integer2),integer3
Description:
This statement is used to set a pixel to a specified color in
medium and high resolution graphics modes. The row is specified in
integer1, the column in integer2, and the color in integer3. Note
that no range checking is performed on integer1 or integer2. A row or
column specified outside the range allowed by the graphics mode in use
can result in unpredictable results.
Example:
PSET (10,20),1
In this example the pixel defined at row 10 and column 20 will be set
to color 1.
See also:
PRESET, SCREEN, POINT
Page - 43
RANDOMIZE
Format: RANDOMIZE
Description:
This statement will cause the seed for the random number
generator to be reseeded using the system timer. This statement
should always precede the first RND statement in your program, unless
you want the same sequence of random numbers generated.
See also:
RND
REM
Format: REM free form comments
Description:
This statement is used to insert comments into your program.
Everything following REM is treated by ASIC as a comment.
RETURN
Format: RETURN
Description:
Used to return from a GOSUB call.
Comments:
Executing a RETURN statement without having first executed a
GOSUB statement could cause unpredictable results.
See also:
GOSUB
Page - 44
RND
Format: integer1 = RND (integer2)
Description:
This statement will return an integer number in the range of 0
through 32767 and store it in integer1. Integer2 is a dummy argument
and can be any valid integer value.
Example:
A = RND(0)
After execution of this statement "A" will contain a number between 0
and 32767 inclusive.
Comments:
In BASICA/GWBASIC, RND always returns a value between 1 and 0,
however, since ASIC only operates with integer values, having the
random number function only return two values seemed ridiculous.
Page - 45
SCREEN
Format: SCREEN integer1
Description:
This statement will transfer the computer from text mode to
medium and high resolution graphics modes. integer1 must be an
integer constant with a value of 0,1 or 2. Screen mode 0 is 25 lines
by 80 columns text with 16 colors. Screen mode 1 is medium resolution
graphics mode with 25 lines by 40 columns text, or 200 rows by 320
columns of pixels with four colors. Screen mode 2 is high resolution
graphics mode with 25 lines by 80 columns of text, or 200 rows by 640
columns of pixels with two colors (black and white).
Example:
SCREEN 1
After execution of this statement, the screen will be in medium
resolution graphics mode.
Comments:
Any program which uses the two graphics modes (1 and 2) should
issue a "SCREEN 0" command before terminating. Otherwise, the screen
will be left in 25x40 character graphics mode which is very irritating
under DOS.
See also:
PSET, PRESET, POINT
Page - 46
SOUND
Format: SOUND integer1,integer2
Description:
This statement will generate a sound on your computer speaker
with a frequency of integer1, and a duration of integer2. Frequency
is in Hertz and should be in the range of 0 to 32767. ASIC, however,
only checks to see that it is non-negative.
Example:
SOUND 400,20
Execution of the above statement will produce a short beep.
STR$
Format: string1 = STR$ (integer1)
Description:
This statement will convert integer1 to a string format and store
the string format in string1.
Example:
A=1234
A$ = STR$(A)
After execution of these statements, A$ would contain the string
"1234".
See also:
VAL
Page - 47
VAL
Format: integer1 = VAL (string1)
Description:
This statement will attempt to convert string1 into an integer
value, and it will store the result in integer1.
Example:
A$ = "12345"
A = VAL (A$)
After execution of these statements, variable "A" would contain the
value 12345.
See also:
STR$
VARPTR
Format: integer1 = VARPTR (variable1)
Description:
This statement will return the address of a variable variable1
and store it in integer1. This may be used to peek and poke values
directly into a variable.
Example:
A$ = "XYZ"
B = VARPTR(A$)
C = PEEK (B)
PRINT C
After execution of these statements the screen would display the
number 88 which is the number for the ASCII character "X".
See also:
PEEK, POKE
Page - 48
WIDTH
Format: WIDTH integer1
Description:
This statement will set the screen to 40 column text or 80 column
text mode only. The only two valid values for integer1 are thus 40
and 80. In ASIC, WIDTH 80 is equivalent to executing SCREEN 0. Also,
WIDTH 40 is equivalent to executing SCREEN 1. If you use WIDTH 40,
you should always reset the screen back to WIDTH 80 before terminating
your program with END. Otherwise, your PC will be left in 40 column
mode.
ZMODE
Format: integer = ZMODE
Description:
This command returns a code which indicates whether a color or
monochrome card is active in the system. ZMODE returns a value of 1
when a color card is detected, and a value of 0 for monochrome.
Example:
A = ZMODE
IF A = 1 THEN CONTINUE:
PRINT "This program requires a Color Card to Run"
END
CONTINUE: REM rest of code follows here
The above code fragment will check for a color card, if not found the
program will terminate with an appropriate message. Otherwise the
program will continue.
Comments:
This statement is an extension over BASICA/GWBASIC.
Page - 49
A S I C
Chapter 7
Compatibility with GWBASIC/BASICA
In general, although ASIC does not support all options on every BASIC
statement, those it does support work like they do in BASICA/GWBASIC.
The known exceptions are listed in this chapter.
INKEY$
This statement is compatible, however ASIC does provide an
extension over GWBASIC/BASICA. If an extended key is pressed (e.g.
F1-F10), ASIC returns the scan code for the extended key, and sets a
special system variable "EXTENDED" to a value of 1. For non-extended
keys, the "EXTENDED" variable will contain 0.
FILE HANDLING
ASIC provides no EOF statement or ON ERROR statements. Instead,
ASIC sets a special system variable when an error occurs during file
I/O. This special variable is called "ERROR" and it is set after
every file I/O statement (OPEN/INPUT#/PRINT#/CLOSE) to either 0 to
indicate no errors, or a non-zero value. If a non-zero value is
present, an error has occurred. The specific errors are identified in
chapter 9.
FILE FORMAT
ASIC Files are written with 2 bytes per integer in binary format,
instead of string format as in BASICA/GWBASIC. Strings are written as
a sequence of ASCII characters terminated by an ASCII null.
Page - 50
PUNCTUATION
ASIC permits use of punctuation that it does not require to allow
you to enter statements in their familiar GWBASIC/BASICA Formats. For
example:
A = ABS (B(1))
This statement is valid in both ASIC and in GWBASIC/BASICA.
However, ASIC ignores the parenthesis and comma. Thus ASIC will
actually accept the following formats as alternatives to the above:
A = ABS B 1
A = ABS B 1,,,,,,)))))
FOR/NEXT
FOR/NEXT loops always fall through the body of the FOR at least
one time in ASIC. This does not happen in BASICA/GWBASIC. For more
information on this, refer to Chapter 6.
RND
RND (N) returns a value from 0-32767 inclusive instead of 0 to 1
as in BASICA/GWBASIC.
ZMODE
ZMODE is an extension over BASICA/GWBASIC. It returns a code
which the program can check to determine if the PC contains a color or
monochrome display adapter card.
Page - 51
A S I C
Chapter 8
Technical Details/Tips
This chapter contains technical information and tips regarding the
ASIC compiler.
COMPILER LIMITS
Maximum Source Program Size: Unlimited - Command Line
809 Lines - Integrated Environment
Maximum Object Program Size: 64k bytes (.COM Format restriction)
Maximum Source Line Length 128 bytes - Command Line
80 bytes - Integrated Environment
Compiler Symbol Table Size: 750+ Symbols
Maximum Number of Arrays: 25
FOR/NEXT Nesting Depth 25
Compiler Memory Requirements 320k - Command Line
400k - Integrated Environment
COMPILER OPERATION
ASIC is a single pass compiler written entirely in C (Borland
Turbo C Version 2.0). Each source statement is translated directly
into machine code. ASIC compiles 100% in memory for maximum speed.
The compiler does not require any disk work space. ASIC generates a
minimum of error checking code. This is because the ASIC philosophy
stresses execution speed. This does place greater responsibility on
the programmer to check for out of bounds conditions, etc..
Page - 52
STORAGE FORMATS
Integers are stored in ASIC as two bytes, with the low order byte
appearing first (as per Intel conventions). String variables are
stored as FIXED 80 character strings terminated by an ASCII null
character for a total length of 81 characters. String constants are
stored with 1 byte per character in the string followed by a
terminating ASCII null character. Each element in an array requires
two bytes. (Don't forget arrays have an element zero (ie DIM A(2) is
comprised of A(0), A(1), and A(2)).
Examples:
Item Data Type Storage Requirements
A Integer Variable 2 bytes
17 Integer Constant 2 bytes
A$ String Variable 81 bytes
"ABC" String Constant 4 bytes
"A" String Constant 2 bytes
DIM A(10) Integer Array 22 bytes
DIM A(1) Integer Array 4 bytes
As you can see, string variables are expensive in terms of storage
space. Since string constants are stored at actual length +1, It is
MUCH more efficient to store short strings as constants in ASIC in
terms of storage space. There is no performance advantage to
constants over variables, however.
In disk files, strings and integers are written out in the above
formats. Note that unlike GWBASIC/BASICA, integers are NOT expanded
into strings when written, and conversely, not converted from strings
to integers when read. String variables and constants are written out
as ASCII strings terminated by a null character. Thus, string
variables when written to disk, take the same space byte for byte as
string constants.
The reason behind fixed length string variables was avoidance of
string "garbage collection". In addition to slight performance
advantages, there is the added benefit of providing a string memory
address which never changes. Thus once VARPTR retrieves the address
of a variable, you never have to worry about it changing.
Page - 53
MEMORY MAP
The following describes the structure of the ".COM" file created by
ASIC. All addresses are in Hexadecimal.
Description Address Range
------------------------------ -------------
Program Segment Prefix (PSP) 0000 - 00FF
(Created/Required by DOS)
Transfer to Program Code 0100 - 0102
String Conversion Buffer 0103 - 0109
Input Buffer 010A - 015B
Screen Width 015C
Color/Attribute Byte 015D
Screen Graphics Mode 015E
Cursor Position 015F - 0160
File Control Table 0161 - 0169
ERROR System Variable 016A - 016B
System Subroutine Vectors 016C - 017F
EXTENDED System Variable 0180 - 0181
RND Seed 0182 - 0185
Math Work Area 0186 - 018D
DEFSEG System Variable 018E - 018F
System Subroutines 0190+
|
|
v
Data Segment Address Varies
|
|
|
v
Code Segment Address Varies
|
|
|
v
^
|
|
Program Stack (builds downward) FFFF
Page - 54
A S I C
Chapter 9
Error Messages
This chapter contains compiler messages, run-time error messages, and
File I/O Error Codes.
COMPILER ERRORS
These messages indicate errors in your source program. Those
which begin with "** E" indicate "fatal" errors, which prevent ASIC
from successfully compiling your program. Warnings begin with "* W"
and indicate possible errors and informative messages which will not
prevent ASIC from generating an executable ".COM" file.
** E001 ** File Extensions must be either ".ASI" or omitted
ASIC requires source programs to have the extension ".ASI".
Rename your source file with the DOS "RENAME" command to the name
"file.ASI", where "file" is your source program name. Then resubmit
the compile.
** E002 ** File Name specified is too long
The source file may be identified by a file name up to 124
characters long including disk drive specifiers and sub directory
names. Move the source program to a directory which may be specified
within this length.
Page - 55
** E003 ** Error Opening File: xxxxxxxx.xxx
The file indicated by "xxxxxxxx.xxx" could not be opened by ASIC.
This error can be issued when ASIC attempts to read your source file,
or when it writes any one of the possible output files (".COM",
".LST", or ".SYM"). If indicated file is your source program name,
verify the spelling, and either make sure it is in the same directory
as ASIC, or specify the full path name for the file. If the indicated
file is an output file, the error is usually a result of a write
protect tab on the diskette or insufficient disk space.
** E004 ** DIM Statements must precede all others
In ASIC, DIM statements must appear before all other statement
types, including REMarks. Move all of your DIM statements to the very
beginning of your source file.
** E005 ** Too many characters in source line
Source program lines in ASIC are limited to 120 characters.
Change the indicated source line, so that it fits within this limit.
** E006 ** Unmatched Quote ('"') in source line
A string constant was found with either no opening or closing
quote mark. Quotation marks must be matched in pairs within source
lines.
** E007 ** Token in source line > 82 characters long
Individual tokens in ASIC are limited to 82 characters in length,
regardless of type. A token is a group of letters and/or numbers
delimited on either side by a space or math symbol. Example, even
though string constants are limited to 80 characters, ASIC considers
the "token" to include the quotation marks. In this case, however,
ASIC detected a token longer than the longest possible token, the
string constant. Check for "tokens" or "words" more than 82
characters long in the indicated source line.
Page - 56
** E008 ** More than 30 tokens in source line
Since all ASIC statements require less than 30 tokens, ASIC will
flag any statement which contains more than this number. A token is a
group of letters and/or numbers delimited on either side by a space or
math symbol.
** E009 ** Keyword Unknown: xxxxxxxxx
ASIC detected the symbol indicated by "xxxxxxxx" in your source
line, but it was not a valid variable name, constant, label, or ASIC
Function Name.
** E010 ** Symbol Table Space Exhausted
The symbol table is used by ASIC to keep track of your variables,
constants and labels. It is also used to hold information used in
FOR/NEXT processing, and internal system subroutine generation.
Reduce the number of LABELS, VARIABLE NAMES, or CONSTANTS in your
program, and recompile.
** E011 ** Symbol Incomplete Reference Space Exhausted
This table is a sister table to the Symbol Table, it contains
references to LABEL type symbols which have been defined in the symbol
table. Try to reduce the number of references made to LABEL symbols
within the program and recompile.
** E012 ** No keywords in source line
Every ASIC source program line must contain an ASIC keyword (eg.
"PRINT", "=", "GOSUB", etc).
** E013 ** Syntax Error
The "catch-all" error for ASIC. This error is usually issued
when ASIC has identified an error in the parameters for an ASIC
keyword. The best way to find this error is to refer to the entry in
the Keyword Reference (chapter 6) for that particular keyword.
Page - 57
** E014 ** Undefined Symbol: xxxxxx
ASIC detected a LABEL "xxxxxx" which was referenced, but never
defined in the program. A label is considered to be defined when it
is the first token on the source line. A reference to a label occurs
when a label name appears elsewhere in the source statement
Example: PRINTIT: PRINT "hello" <---Defined
GOTO PRINTIT: <--Referenced
** E015 ** Compiled Code Exceeds 64k-Can't fit in .COM file
Your source program is too large to fit in the .COM file format.
Eliminate extraneous variables and program statements. Note: REM
statements do NOT generate any output code, so elimination of REM
statements will not alleviate this problem.
** E016 ** Integer Constant Not in range +32767 to -32767
The above range of numbers is the maximum which can be contained
in integer format in ASIC. Reduce the constant so that it falls
within the specified range.
** E017 ** Duplicate Label: xxxxxx
The indicated label "xxxxxx" was defined more than once in the
program. Reduce the multiple definitions to a single definition and
then recompile.
** E018 ** Second FOR defined for variable with no intervening NEXT
FOR/NEXT Statements cannot be nested with the same variable name.
VALID INVALID
FOR I=1 TO 10 FOR I=1 TO 10
FOR J=1 TO 20 FOR I=1 TO 20
NEXT J NEXT I
NEXT I NEXT I
Page - 58
** E019 ** For/Next Table Space Exhausted
An unlimited of FOR/NEXT statements can exist, however, they can
be "nested" to a maximum depth of 25.
** E020 ** NEXT without FOR
A NEXT statement was found, however it was not preceded in the
source program with a matching FOR statement.
** E021 ** FOR without NEXT at Source Line NNNNN
The indicated source line NNNNN contains a FOR statement, for
which no NEXT statement was ever found.
** E022 ** Invalid Option: x
An invalid compile option was specified. Review Chapter 4 for a
list of valid compile options.
** E023 ** More than 63000 bytes in Data Segment
An ASIC program can be up to 64k bytes in size. Of this total,
63000 bytes can contain program variables and constants, leaving at
least 1k for program code. Reduce the number of variables and
constants in your program.
** E024 ** Too many arrays defined
A single ASIC source program can contain up to 25 arrays.
** E025 ** Re-DIMension of previously DIMensioned variable
Only one DIM statement can be specified per array name.
Page - 59
** E026 ** Invalid subscript on Array
A subscript was found which is not valid. Either ASIC expected
more or less subscripts than were present, or ASIC detected a
subscript which was itself an array. Subscripts on arrays may only be
non-array variables and/or integer constants.
** E027 ** String Arrays Are Not Supported
A DIM statement specified a string variable type. Only integer
arrays are supported.
** E028 ** Comfile Buffer - Memory Allocation Failed
ASIC attempted to allocate memory for an internal buffer . This
memory allocation failed. More memory is required. If you have any
TSR's loaded in memory, remove them and try again.
** E029 ** Codeseg Buffer - Memory Allocation Failed.
ASIC attempted to allocate memory for an internal buffer. This
memory allocation failed. More memory is required. If you have any
TSR's are loaded in memory, remove them and try again.
** E030 ** Code Segment Memory Exhausted
ASIC will attempt to allocate 64k of memory to use a work space
to hold the code generated by your program statements. This message
indicates that the amount of memory it was able to allocate was not
sufficient to hold the code generated by the program you are trying to
compile.
** E031 ** Data Segment Memory Exhausted
ASIC will attempt to allocate 64k of memory to use a work space
to hold the data segment for your program. This message indicates
that the amount of memory it was able to allocate was not sufficient
to hold the data generated by the program you are trying to compile.
Page - 60
** E032 ** Insufficient Memory to Run ASIC
You don't have enough memory to run ASIC. If you have any TSR's
loaded, try removing them and re-compiling.
** E033 ** Edit Buffer Memory Allocation Failed
ASIC attempted to allocate memory for the edit buffer in the
integrated environment, but was unable to. If you have any TSR's
loaded, remove them from memory, and try again.
* W001 * Last Statement Not END -- END supplied
Warning only. Asic expects the last statement of a program to be
an END statement. If it does not find one, it generates one for you.
* W002 * Printer Not Ready - 'P' Option Ignored
You selected the "Printer" option, but ASIC was not able to
access the printer. Make sure the printer is online before compiling
with the 'P' option.
* W004 * Edit Buffer Full--File Truncated
While loading a file, the edit buffer filled before ASIC reached
end-of-file. The file is truncated in memory. IF YOU SAVE THE FILE
AFTER RECEIVING THIS MESSAGE, PART OF THE FILE WILL BE LOST ON DISK.
IT IS RECOMMENDED THAT YOU EITHER EXIT ASIC IMMEDIATELY, OR THAT YOU
SAVE THE TRUNCATED FILE UNDER A NEW NAME SO THAT THE ORIGINAL FILE IS
NOT DAMAGED.
Page - 61
* W005 * Edit Buffer Full
ASIC issues this message when the edit buffer is full and you
attempt to insert a line. Delete some unnecessary source lines to
create space in the edit buffer.
* W006 * Source/Dest of Block Copy/Move May Not Overlap
You attempted to move or copy a block of lines to a destination
line which was within the source block of lines. Execution of this
block move/copy would result in an endless series of copies or moves.
Move the cursor outside of the highlighted block of lines, and try
again.
Page - 62
RUN TIME ERRORS
Divide Overflow
This message indicates that your program attempted to divide by
zero.
Page - 63
FILE I/O ERRORS
ERROR Codes Set by OPEN --- Mode Input
000 No Error
002 File Not Found
004 File Not Found
005 File Access Denied
254 File Number Already in Use
ERROR Codes Set by OPEN --- Mode Output
000 No Error
003 Path Not Found
004 No File Handle Available
005 File Access Denied
254 File Number Already in Use
ERROR Codes Set by CLOSE
000 No Error
006 Invalid Handle
095 Cannot Close File -- File is not Open
ERROR Codes Set by INPUT#
000 No Error
005 Read Access Denied
006 Invalid File Handle
096 Input String Truncated at 80 Characters
098 File Not Open for Input
099 End of File
ERROR Codes Set by PRINT#
000 No Error
005 File Access Denied
006 Invalid File Handle
097 File Not Open for Output
255 Disk Full
Page - 64